using Services;
using UnityEngine;

[DefaultExecutionOrder(-100)]
public class ContainerUI_Manager_Bag : ContainerUI_Manager
{
    protected override void Start()
    {
        base.Start();
        ServiceLocator.Get<EventSystem>().AddListener<EGameState, EGameState>(EEvent.GameStateChange, OnGameStateChange);
        Container = Player.Bag;
    }

    private void OnGameStateChange(EGameState from, EGameState to)
    {
        switch (to)
        {
            case EGameState.OpenBag:
            case EGameState.OpenStorage:
            case EGameState.Purchase:
                backGround.sprite = Container.backgroundOfPanel;
                Panel.frameOfItem = Container.frameOfItem;
                VisibleChange?.Invoke(true);
                break;
            default:
                VisibleChange?.Invoke(false);
                break;
        }
    }
}